/**----------------------------------------
 * @description 资源管理类
 * @author      lxc
 * @file        ResourceManager.ts
 * @Date        2022-05-05
 * @version     1.0.0
 * ----------------------------------------
 */

import { LogClass } from "../LogClass";
import { PrefabPath } from "./PathConstant";

export class ResourceManager extends LogClass{

    private cacheResMap = null;

    /** ts语法糖来控制类型 */
    loadPrefab : (path : PrefabPath, callback ?: Function) => void = null;

    constructor(){
        super()
        this.loadPrefab = (prefabPath : any, callback ?: Function) => {
            cc.resources.load(prefabPath, cc.Prefab, (err,prefab)=>{
                if(err){
                    this.printError("prefab load fail" , prefabPath, err)
                    return;
                }
                callback && callback(prefab);
            })
        }
    }
}